import allure
import pytest
import requests
import os
import time
from .data import load_Logindata
basedir=os.path.dirname(__file__)
filepath=os.path.join(basedir,"testCase/login.json")
@allure.epic("登录接口")
class TestLogin:
    def setup_class(self):
        print("登录接口测试开始：",time.strftime("%Y-%m-%d-%H:%M:%S"))
    def teardown_class(self):
        print("登录接口测试结束：",time.strftime("%Y-%m-%d-%H:%M:%S"))
    @pytest.mark.parametrize("testCase,username,password,msg,status_code",load_Logindata(filepath))
    @allure.title("{testCase}")
    def test_Login(self,testCase,username,password,msg,status_code):
        self.url="http://127.0.0.1:8000/login"
        login_data={
            "username":username,
            "password":password,
        }
        responses=requests.post(self.url,data=login_data)
        assert status_code==responses.status_code
        assert msg in responses.text
